import requests

# 定义url
url = "https://nmtp.youdao.com/api/organize/1514708/image/upload"
# 定义接口请求头部信息
header = {
    'Cookie': 'ga=GA1.2.1193743571.1646906746; OUTFOX_SEARCH_USER_ID_NCOO=37296470.23531183; OUTFOX_SEARCH_USER_ID="1446041502@10.110.96.154"; _gid=GA1.2.1397755351.1663074911; _gat=1; SESSION=7344a696-6840-4ee7-a5fa-83ab4f76bdef; NTES_SESS=alUCVX5Km6Iv1e7fKG.gWrJfYncGB.41wnN4uJtNc91o490e4zw3CZR7Gq_OchVQHyLG6rXHRhJz8k2_X8C7nY02VSTdEDR1NMGammRCs3em1r5CHIMcqyqHdxUXrDAKcQsbSPvfqpqmkOegG6hnmT2EBvf.jtfeSeNqGXgc75cjpTVpofBBl7QC.uNxJddx6shCzI7EMjze8TASM5GPGFe8g; S_INFO=1663074926|0|##|974381044@qq.com; P_INFO=974381044@qq.com|1663074926|0|youdao_jianwai|00&99|null&null&null#sic&511300#10#0#0|&0|youdao_jianwai|974381044@qq.com',
}
# 定义上传文件
file = {'file': open(r"C:\TT\习知\课件\我的课件\1624958787(1).png", "rb")}

# 请求接口
# rep = requests.post(url=url, headers=header, files=file)
# print(rep.text)

rep = requests.request(method='post', url=url, headers=header, files=file)
# print(rep.encoding)  # 接口响应的编码格式
# rep.encoding = 'gbk'  # 设置编码格式
# print(rep.encoding)
# print(rep.text)         # 以encoding解析返回内容。字符串方式的响应体，会自动根据响应头部的字符编码进行解码
# print(type(rep.text))
# rep_baidu = requests.request(method='get', url="https://www.baidu.com")
# print(rep_baidu.cookies)    # 返回cookie
# print(rep.headers)          # 响应头信息
# print(rep.status_code)        # 响应码
# print(rep.json())             # 返货json格式数据